home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Functions_String"
- Option Explicit
-
-
- Public Function TrimNull(ByVal What As String)
-
- ' Function: TrimNull
- '
- ' Takes a string as input and returns
- ' a string with all instances of the
- ' null character Chr$(0), leading and
- ' trailing spaces, and vbCrLf removed.
-
- What = Trim$(What)
- If InStr(What, Chr(0)) <> 0 Then What = RemoveChar(What, Chr(0))
- If InStr(What, vbCrLf) <> 0 Then What = RemoveChar(What, vbCrLf)
-
- Do: DoEvents
- If Right(What, 1) = Chr(10) Or Right(What, 1) = Chr(13) Then What = Mid(What, 1, Len(What) - 1)
- Loop Until Right(What, 1) <> Chr(10) And Right(What, 1) <> Chr(13)
-
- Do: DoEvents
- If Left(What, 1) = Chr(10) Or Left(What, 1) = Chr(13) Then What = Mid(What, 2)
- Loop Until Left(What, 1) <> Chr(10) And Left(What, 1) <> Chr(13)
-
- TrimNull = What
-
- End Function
-
- Public Function RemoveChar$(ByVal Buf As String, ByVal Char As String)
-
- ' Function: RemoveChar$
- '
- ' Removes all occurrences of 'Char' in 'Buf'
- ' and returns the new string
-
- Dim Check%
- Dim LeftOf$, RightOf$
-
- Do
- DoEvents
- Check% = InStr(Buf$, Char$)
- If Check% > 0 Then
- LeftOf$ = Left(Buf$, Check% - 1)
- RightOf$ = Right(Buf$, Len(Buf$) - Check%)
- Buf$ = LeftOf$ & RightOf$
- End If
- Loop Until Check% = 0
-
- RemoveChar$ = Buf$
-
- End Function
-
- Public Function StripQuotes(ByVal StringWithQuotes As String) As String
-
- ' Function: StripQuotes
- '
- ' Returns: This function simply returns StringWithQuotes
- ' with quotation marks on the left and right side stripped away.
-
- If StringWithQuotes = "" Then Exit Function
-
- If Left(StringWithQuotes, 1) = Chr(34) Then
- StringWithQuotes = Mid(StringWithQuotes, 2)
- End If
-
- If Right(StringWithQuotes, 1) = Chr(34) Then
- StringWithQuotes = Mid(StringWithQuotes, 1, Len(StringWithQuotes) - 1)
- End If
-
- StripQuotes = StringWithQuotes
-
- End Function
-